package cn.gson.crmdemo.model.service;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.gson.crmdemo.model.dao.EmpDao;
import cn.gson.crmdemo.model.mapper.LoginMapper;
import cn.gson.crmdemo.model.pojo.Emp;

@Service
@Transactional(rollbackFor=Exception.class)
public class LoginService {
	@Autowired
	EmpDao edao;
	@Autowired
	LoginMapper lm;
	
	/**
	 * 登录
	 */
	public Emp login(String root,String pass) {
		Emp emp = lm.login(root, pass);
		if(emp != null) {
			Emp emp2 = edao.findById(emp.getEmpId()).get();
			emp2.setEmpLoginType(1);
		}
		return emp;
	}
	/**
	 * 注销
	 */
	public void cancellation(Integer empId) {
		Emp emp = edao.findById(empId).get();
		emp.setEmpLoginType(0);
	}
	/*public JSONArray login(String root,String pass) {
		return lm.login(root, pass);
		
	}*/
}
